#ifndef LOCK_H
#define LOCK_H

#include "lockable.hpp"
namespace vpm 
{
	namespace utils
	{

		enum LockType
		{
			LOCK = 0,
			READLOCK,
			WRITELOCK
		};

		/**
		A convenience class to lock a Lockable (such as a Mutex) on object creation,
		and unlock on destruction.
		@see Mutex
		*/
		class Lock
		{
		public:
			/**
			@param	Lockable&	The object to lock
			@param	LockType	one of VOCAL_LOCK, VOCAL_READLOCK, VOCAL_WRITELOCK
			*/
			Lock(Lockable &, LockType = LOCK);
			virtual ~Lock();

		private:
			Lockable&   myLockable;
		};

		class ReadLock : public Lock
		{
		public:
			ReadLock(Lockable &);
		};

		class WriteLock : public Lock
		{
		public:
			WriteLock(Lockable &);
		};

	}
}
#endif
